\documentclass[paper=a4, fontsize=11pt]{scrartcl} % A4 paper and 11pt font size

\usepackage[T1]{fontenc} % Use 8-bit encoding that has 256 glyphs
\usepackage{fourier} % Use the Adobe Utopia font for the document - comment this line to return to the LaTeX default
\usepackage[english]{babel} % English language/hyphenation
\usepackage{amsmath,amsfonts,amsthm} % Math packages
\usepackage[UTF8]{ctex}
\usepackage{xcolor}
\usepackage{listings}
\usepackage{tikz}
\usepackage{lipsum} % Used for inserting dummy 'Lorem ipsum' text into the template
\usepackage{clrscode}
\usepackage{sectsty} % Allows customizing section commands
\usepackage[framed,numbered,autolinebreaks,useliterate]{mcode}
\usepackage{multirow}
\usepackage{graphicx}
\usepackage{float}
\usetikzlibrary{graphs}
\usetikzlibrary{shapes.arrows}
\allsectionsfont{\centering \normalfont\scshape} % Make all sections centered, the default font and small caps

\usepackage{fancyhdr} % Custom headers and footers
\pagestyle{fancyplain} % Makes all pages in the document conform to the custom headers and footers
\fancyhead{} % No page header - if you want one, create it in the same way as the footers below
\fancyfoot[L]{} % Empty left footer
\fancyfoot[C]{} % Empty center footer
\fancyfoot[R]{\thepage} % Page numbering for right footer
\renewcommand{\headrulewidth}{0pt} % Remove header underlines
\renewcommand{\footrulewidth}{0pt} % Remove footer underlines
\setlength{\headheight}{13.6pt} % Customize the height of the header

\numberwithin{equation}{section} % Number equations within sections (i.e. 1.1, 1.2, 2.1, 2.2 instead of 1, 2, 3, 4)
\numberwithin{figure}{section} % Number figures within sections (i.e. 1.1, 1.2, 2.1, 2.2 instead of 1, 2, 3, 4)
\numberwithin{table}{section} % Number tables within sections (i.e. 1.1, 1.2, 2.1, 2.2 instead of 1, 2, 3, 4)

\setlength\parindent{0pt} % Removes all indentation from paragraphs - comment this line for an assignment with lots of text

%----------------------------------------------------------------------------------------
%	TITLE SECTION
%----------------------------------------------------------------------------------------

\newcommand{\horrule}[1]{\rule{\linewidth}{#1}} % Create horizontal rule command with 1 argument of height

\title{
\normalfont \normalsize
\textsc{中国科学院大学}\ \textsc{计算机与控制学院} \\ [25pt] % Your university, school and/or department name(s)
\horrule{0.5pt} \\[0.4cm] % Thin top horizontal rule
\huge 图像处理与分析第三次作业 \\ % The assignment title
\horrule{2pt} \\[0.5cm] % Thick bottom horizontal rule
}

\author{黎吉国&201618013229046} % Your name

\date{\normalsize\today} % Today's date or a custom date

\begin{document}

\maketitle % Print the title

\newpage
\section{answer for 1st}
高斯型低通滤波器在频域中的传递函数是
\[ H(u,v)=Ae^{-(u^2+v^2)/2\sigma^2} \]
根据二维傅里叶的性质证明其空域的响应形式滤波器形式为
\[ h(x,y)=A2\pi\sigma^2 e^{-2\pi^2\sigma^2(x^2+y^2)} \]
已知如下结论：$ f(x,y)=e^{\pi(x^2+y^2)} $的傅里叶变换为$ F(u,v)=e^{-\pi (u^2+v^2)} $。\\
\textbf{Solution:}\\
由已知可得，
\begin{equation*}
  \mathcal{F}(e^{-\pi(x^2+y^2)})=\int_{-\infty}^{+\infty}\int_{-\infty}^{+\infty}e^{-\pi(x^2+y^2)}e^{-j2\pi(ux+vy)}dxdy
  =e^{-\pi(u^2+v^2)}
\end{equation*}

我们的目标是求$h(x,y)=A2\pi\sigma^2 e^{-2\pi^2\sigma^2(x^2+y^2)}$的傅里叶变换。（时域的函数与频域的函数一一对应）
\begin{equation*}
  \begin{split}
\mathcal{F}(h(x,y))&=\int_{-\infty}^{+\infty}\int_{-\infty}^{+\infty}A2\pi\sigma^2 e^{-2\pi^2\sigma^2(x^2+y^2)}e^{-j2\pi(ux+vy)} dxdy\\
let\ & x'=\sqrt{2\pi}\sigma x,\ y'=\sqrt{2\pi}\sigma y\\
left &= A\int_{-\infty}^{+\infty}\int_{-\infty}^{+\infty}e^{-\pi(x'^2+y'^2)}e^{-j2\pi(\frac{u}{\sqrt{2\pi}\sigma}x'+\frac{v}{\sqrt{2\pi}\sigma}y')}dx'dy'\\
&= Ae^{-\pi((\frac{u}{\sqrt{2\pi}\sigma})^2+(\frac{v}{\sqrt{2\pi}\sigma})^2)}\\
&= Ae^{-\pi(u^2+v^2)/2\sigma^2}
\end{split}
\end{equation*}
得证.

\newpage
\section{answer for 2ed}
\begin{enumerate}
  \item 证明下式的正确性
  \[ \mathcal{F}[f(x,y)(-1)^{x+y}]=F(u-M/2,v-N/2) \]
  \item 证明傅里叶变换在时域和频域的平移特性。
  \[ f(x,y)e^{j2\pi (u_0 x/M + v_0 y/N)} \leftrightarrow F(u-u_0,v-v_0) \]
  \[ f(x-x_0,y-y_0) \leftrightarrow F(u,v)e^{-j2\pi(ux_0/M+vy_0/N)} \]
\end{enumerate}
\textbf{基础知识：}
\begin{itemize}
  \item 一维连续函数的傅里叶变换
  \[ F(\omega)=\int_{-\infty}^{+\infty}f(x)e^{-j2\pi \omega x}dx \]
  \item 二维连续函数的傅里叶变换
  \[ F(u,v)=\int_{-\infty}^{+\infty}\int_{-\infty}^{+\infty} f(x,y)e^{-j2\pi(ux+vy)}dxdy \]
  \item 二维离散傅里叶变换
  \[ F(u,v)=\sum_{x=0}^{M}\sum_{y=0}^{N} f(x,y)e^{-j2\pi(ux/M+vy/N)} \]
\end{itemize}
\textbf{Solution:}
\begin{enumerate}
\item 要证明$ \mathcal{F}[f(x,y)(-1)^{x+y}]=F(u-M/2,v-N/2) $\\
因为
\[ left= \int_{-\infty}^{+\infty}\int_{-\infty}^{+\infty} f(x,y)(-1)^{x+y}e^{-j2\pi(ux/M+vy/N)}dxdy \]
\[ right= \int_{-\infty}^{+\infty}\int_{-\infty}^{+\infty} f(x,y)e^{-j2\pi((u-M/2)x+(v-N/2)y)}dxdy=\int_{-\infty}^{+\infty}\int_{-\infty}^{+\infty} f(x,y)e^{-j2\pi(ux/M+vy/N)}e^{j\pi(x+y)}dxdy \]
只需证明$(-1)^{x+y}=e^{j\pi(x+y)}$
\[ right=\cos{(x+y)\pi}+j\sin{(x+y)\pi}=
\begin{cases}
  1 &\mbox x+y\ is \ even\\
  -1 &\mbox x+y\ is\ odd
\end{cases}
 \]
 易得
 \[
 (-1)^{x+y}=e^{j\pi(x+y)}=
 \begin{cases}
   1 &\mbox x+y\ is \ even\\
   -1 &\mbox x+y\ is\ odd
 \end{cases}
 \]
 得证.
 \item
 \begin{enumerate}
   \item 频移特性
   \begin{equation*}
     \begin{split}
     \mathcal{F}[f(x,y)e^{j2\pi (u_0 x/M + v_0 y/N)}]&=\sum_{x=0}^{M-1}\sum_{y=0}^{N-1} f(x,y)e^{j2\pi (u_0 x/M + v_0 y/N)}e^{-j2\pi(ux/M+vy/N)}\\
     &=\sum_{x=0}^{M-1}\sum_{y=0}^{N-1} f(x,y)e^{-j2\pi((u-u_0)x/M+(v-v_0)y/N)}\\
     &=F(u-u_0,v-v_0)
   \end{split}
   \end{equation*}
   \item 时移特性
   \begin{equation*}
     \begin{split}
     \mathcal{F}[f(x-x_0,y-y_0)]&=\sum_{x=0}^{M-1}\sum_{y=0}^{N-1} f(x-x_0,y-y_0)e^{-j2\pi(ux/M+vy/N)}\\
     &=\sum_{x-x_0=0}^{M-1}\sum_{y-y_0=0}^{N-1} f(x-x_0,y-y_0)e^{-j2\pi(u(x-x_0)/M+v(y-y_0)/N)}e^{-j2\pi(ux_0+vy_0)}\\
     &=F(u,v)e^{-j2\pi(ux_0+vy_0)}
   \end{split}
   \end{equation*}
 \end{enumerate}
 得证.
\end{enumerate}

\newpage
\section{answer for 3th}
观察如下所示图像，右边的图像通过这样的操作得到：
\begin{enumerate}
  \item 在原始图的左边乘以$(-1)^{x+y}$
  \item 计算离散傅里叶变换
  \item 对变换取共轭
  \item 计算傅里叶反变换
  \item 结果的是不再乘以$(-1)^{x+y}$
\end{enumerate}
用数学方法解释为什么会出现右图的效果。
\begin{figure}[H]
\centering
\includegraphics[width=3in,height=1.5in]{dip.jpg}
\caption{dip}
\label{fig:graph}
\end{figure}
\textbf{Solution:}\\
我们设定左图为$f(x,y)$,右图为$g(x,y)$，则观察可得，两者之间的关系为
$g(x_0,y_0)=f(M-x_0,N-y_0)$或者$g(x_0,y_0)=f(-x_0,-y_0)$。我们可以向这两个方向努力。经过验证，第一个式子不可证，变换过程满足第二个式子。下面分别实现每一个步骤来验证该结论。\\
初始图像为$f(x,y)$
\begin{enumerate}
\item $f(x,y)(-1)^{x+y}$
\item $\sum_{x=0}^{M-1}\sum_{y=0}^{N-1}f(x,y)(-1)^{x+y}e^{-2\pi j (ux/M+vy/N)}  $
\item 取共轭:$\sum_{x=0}^{M-1}\sum_{y=0}^{N-1}f(x,y)(-1)^{x+y}e^{2\pi j (ux/M+vy/N)}  $
\item 反变换:$\frac{1}{MN}\sum_{u=0}^{M-1}\sum_{v=0}^{N-1} [\sum_{x=0}^{M-1}\sum_{y=0}^{N-1}f(x,y)(-1)^{x+y}e^{2\pi j (ux/M+vy/N)}]e^{2\pi j (ux'/M+vy'/N)}  $
\item 取实部，乘以$(-1)^{x+y}$: $(-1)^{x'+y'}Re\{\frac{1}{MN}\sum_{u=0}^{M-1}\sum_{v=0}^{N-1} [\sum_{x=0}^{M-1}\sum_{y=0}^{N-1}f(x,y)(-1)^{x+y}e^{2\pi j (ux/M+vy/N)}]e^{2\pi j (ux'/M+vy'/N)}
  \}$,设这里的结果为$g(x,y)$.
\end{enumerate}
这里我们要证$g(x_0,y_0)=f(-x_0,-y_0)$.\\
\begin{equation*}
\begin{split}
g(x_0,y_0)&=(-1)^{x_0+y_0}Re\{\frac{1}{MN}\sum_{u=0}^{M-1}\sum_{v=0}^{N-1} [\sum_{x=0}^{M-1}\sum_{y=0}^{N-1}f(x,y)(-1)^{x+y}e^{2\pi j (ux/M+vy/N)}]e^{2\pi j (ux_0/M+vy_0/N)}\}\\
&\text{这里我们想办法把对}u,v\text{的积分放到里面}\\
left\ &=(-1)^{x_0+y_0}Re\{\frac{1}{MN} \sum_{x=0}^{M-1}\sum_{y=0}^{N-1}f(x,y)e^{j\pi(x+y)}[\sum_{u=0}^{M-1}\sum_{v=0}^{N-1}e^{2\pi j (u(x+x_0)/M+v(y+y_0)/N)}]\}\\
& \frac{1}{MN}\sum_{u=0}^{M-1}\sum_{v=0}^{N-1}e^{2\pi j (u(x+x_0)/M+v(y+y_0)/N)}=\mathcal(F)^{-1}(1)|_{x=x+x_0,y=y+y_0}=\delta(x+x_0,y+y_0)\}\\
left\ &=(-1)^{x_0+y_0}Re\{\sum_{x=0}^{M-1}\sum_{y=0}^{N-1}f(x,y)e^{j\pi(x+y)}\delta(x+x_0,y+y_0)\}\\
& \text{由}\delta(t)的抽样性质.\\
left\ &=(-1)^{x_0+y_0}Re\{ f(-x_0,-y_0)e^{j\pi(x_0+y_0)}\}\\
&=(-1){2(x_0+y_0)}f(-x_0,-y_0)
\end{split}
\end{equation*}
得证.

\newpage
\section{answer for 4th}
分别测试一幅图像在频域做如下处理，其在时域的处理效果：
\begin{enumerate}
\item 取共轭
\item 尺度变换
\item 理想窗函数
\end{enumerate}
测试结果：
\begin{enumerate}
  \item 频域取共轭
  \begin{figure}[H]
  \centering
  \includegraphics[width=4in,height=3in]{conjugate.jpg}
  \caption{频域共轭}
  \label{fig:graph}
  \end{figure}
可见频域去共轭相当于时域的旋转。
  \item 尺度变换
  \begin{figure}[H]
  \centering
  \includegraphics[width=4in,height=3in]{scale.jpg}
  \caption{尺度变换,scale=0.5}
  \label{fig:graph}
  \end{figure}
  可见频域的尺度变换相当于时域的亮度变换。
  \item 理想窗函数
  \begin{figure}[H]
  \centering
  \includegraphics[width=4in,height=3in]{window.jpg}
  \caption{理想窗函数,window\_len=0.2}
  \label{fig:graph}
  \end{figure}
  可见频域的窗函数相当于时域的低通滤波。
\end{enumerate}

\end{document}
